<html>
<head>
    <#assign basePath=request.contextPath>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>后台管理系统</title>
    <!-- Bootstrap Core CSS -->
    <link href="${basePath}/bootstrap/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
<div id="page-wrapper" style="padding: 0 15px;">
    <div class="row">
        <div class="col-lg-12">
            <br>
            <div class="panel panel-default">
                <div class="panel-body">
                    <form role="myForm">
                        <div class="form-group input-group">
                            <span class="input-group-addon">原密码</span>
                            <input type="password" class="form-control" name="oldPassword" id="oldPassword" >
                        </div>
                        <div class="form-group input-group">
                            <span class="input-group-addon">新密码</span>
                            <input type="password" class="form-control" name="newPassword" id="newPassword">
                        </div>
                        <div class="form-group input-group">
                            <span class="input-group-addon">重复密码</span>
                            <input type="password" class="form-control" name="plainPassword" id="plainPassword">
                        </div>
                        <hr>
                        <div class="row" align="center">
                            <div class="col-xs-12">
                                <button type="button" class="btn btn-primary" onclick="submitForm();">确定</button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>

<script src="${basePath}/bootstrap/js/jquery.min.js" type="text/javascript"></script>
<script src="${basePath}/bootstrap/js/bootstrap.min.js" type="text/javascript"></script>
<script src="http://cdn.bootcss.com/blueimp-md5/1.1.0/js/md5.js"></script>
<!-- layer JavaScript -->
<script src="${basePath}/bootstrap/plugin/layer/layer.js" type="text/javascript"></script>
<script>
    var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
    //关闭窗口并刷新页面
    function closePage() {
        parent.layer.close(index);
    }

    function submitForm() {
        var param = 'oldPassword=' + md5($('#oldPassword').val() )+ '&newPassword=' + md5($('#newPassword').val())
                + '&plainPassword=' + $('#plainPassword').val();
        $.ajax({
            type:'POST',
            url: '${basePath}/admin/manager/changePwd?' + param,
            dataType: 'json',
            success: function (data) {
                 if (data.code == '0' ) {
                    layer.alert('密码修改成功，请重新登录', {
                        icon : 6
                    });
                    closePage();
                    location.href = '${basePath}/admin/logout';
                }else{
                    layer.alert(data.desc, {
                        icon : 5
                    });
                }
            },
            error: function(){

            }
        });
    }

</script>
</body>
</html>

